{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Neural networks<br>How they work and their future in science\n",
    "\n",
    "Tom Charnock\n",
    "\n",
    "Institut d'Astrophysique de Paris\n",
    "<br><br><br>\n",
    "\n",
    "<div class=\"row\">\n",
    "    <div style=\"float: left; width: 20%; padding-right: 70px; padding-top:35px\">\n",
    "        <img src=\"../figures/SU.png\" alt=\"Sorbonne Université\" style=\"width:80%;\"/>\n",
    "    </div>\n",
    "    <div style=\"float: left; width: 20%; padding: 0px;\">\n",
    "        <img src=\"../figures/ANR.png\" alt=\"ANR\" style=\"width:40%;\"/>\n",
    "    </div>\n",
    "    <div style=\"float: left; width: 20%; padding: 5px;\">\n",
    "        <img src=\"../figures/IAP.png\" alt=\"IAP\" style=\"width:40%;\"/>\n",
    "    </div>\n",
    "    <div style=\"float: left; width: 20%; padding: 5px;\">\n",
    "        <img src=\"../figures/CNRS.png\" alt=\"CNRS\" style=\"width:30%;\"/>\n",
    "    </div>\n",
    "    <div style=\"float: left; width: 20%; padding: 5px;\">\n",
    "        <img src=\"../figures/Aquila.png\" alt=\"Aquila\" style=\"width:60%;\"/>\n",
    "    </div>\n",
    "</div> "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## What is a neural network?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Neural networks are arbitrary fittable non-linear functions\n",
    "<br>\n",
    "<img style=\"max-width:65%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/neural_network_t.svg\">\n",
    "<br>\n",
    "<center>$$\\mathscr{f} : {\\bf d}\\to\\boldsymbol{\\tau}$$</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### There are many different architectures\n",
    "<br>\n",
    "<div style=\"float:left;width:50%;\">\n",
    "    <b>Convolutional neural networks</b>\n",
    "    <br><br>\n",
    "    <img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/convolutional_network.svg\">\n",
    "</div>\n",
    "<div style=\"float:left;width:50%;\">\n",
    "    <b>Recurrent neural networks</b>\n",
    "    <br><br>\n",
    "    <img style=\"max-width:80%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/RNN.svg\">\n",
    "    <br>\n",
    "</div>\n",
    "<b>For any given dataset there is generally an obvious choice of architecture</b>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## How to fit a neural network"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "<br><br>\n",
    "<center><b>Approximate a function, $\\mathscr{g} : {\\bf d}\\to\\boldsymbol{\\theta}$, <br>with a neural network, $\\mathscr{f} : {\\bf d}\\to\\boldsymbol{\\tau}$</b></center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Probabilistic interpretation of a neural network\n",
    "<br>\n",
    "<img style=\"max-width:95%;max-height:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/Flat_likelihood_theta.svg\">\n",
    "<b>How likely is any network going to provide the expected function output?</b>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "This surface is defined by our choice in distance measure which is called the <i>cost</i> or <i>loss</i> function"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Obtaining informative outputs\n",
    "$$\\mathcal{P}(\\boldsymbol{\\theta}|{\\bf d})= \\int d\\boldsymbol{\\omega}d\\boldsymbol{\\alpha}~\\mathcal{L}(\\boldsymbol{\\theta}|{\\bf d},\\boldsymbol{\\omega},\\boldsymbol{\\alpha})\\mathcal{P}(\\boldsymbol{\\omega},\\boldsymbol{\\alpha})$$\n",
    "<br><br>\n",
    "<img style=\"max-width:100%;max-height:50%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/posterior_predictive_theta.gif\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Maximum likelihood estimate of weights\n",
    "<br><br>\n",
    "<img style=\"max-width:90%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/mle_net_theta.gif\">\n",
    "<br><br>\n",
    "$$\\boldsymbol{\\omega}^\\textrm{MLE}=\\underset{\\boldsymbol{\\omega}}{\\textrm{argmax}}\\left[\\mathcal{L}(\\boldsymbol{\\{}\\boldsymbol{\\theta}\\boldsymbol{\\}}^\\textrm{train}|\\boldsymbol{\\{}{\\bf d}\\boldsymbol{\\}}^\\textrm{train}, \\boldsymbol{\\omega}, \\boldsymbol{\\alpha}^*)\\right]$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Prediction using neural networks\n",
    "<br><br>\n",
    "<img style=\"max-width:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/nn_b_theta.gif\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Why do we use neural networks?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### They're quick and (relatively) cheap"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "#### Like how FFT are more efficient than directly evaluating Fourier Transforms\n",
    "#### Neural networks can fit extremely complex functions to run blazingly quickly"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Super-resolution and super-approximation of dark matter simulations\n",
    "<br>\n",
    "<div style=\"float:left;width:45%;\">\n",
    "    <center><b>Emulating high resolution N-body simulations</b></center>\n",
    "    <img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/high_resolution_predictions_incep_7x7x7_light.png\">\n",
    "</div>\n",
    "<div style=\"float:left;width:10%;\">\n",
    "    &nbsp;\n",
    "</div>\n",
    "<div style=\"float:left;width:45%;\">\n",
    "    <center><b>Inpainting high quality observable quantities</b></center>\n",
    "    <img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/visual_comparison_N500_inset.png\">\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Neural networks are driven by data\n",
    "#### i.e. they can be fit with data where there is no description via a physical model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "<br>\n",
    "<div style=\"float:left;width:45%;\">\n",
    "    <center><b>Generating images of faces</b></center>\n",
    "    <br>\n",
    "    <img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/generated_faces.png\">\n",
    "</div>\n",
    "<div style=\"float:left;width:10%\">\n",
    "    &nbsp;\n",
    "</div>\n",
    "<div style=\"float:left;width:45%;\">\n",
    "    <center><b>Detecting tumours for aided cancer discovery</b></center>\n",
    "    <br>\n",
    "    <img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/ai-cancer.png\">\n",
    "</div>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "skip"
    }
   },
   "source": [
    "Maybe put galaxy classification test?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Physical models from data models"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Data models are the description that include all effects that generate the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "<div style=\"float:left;width:50%;\">\n",
    "    <h3>Initial conditions</h3>\n",
    "    <h3>Physical model</h3>\n",
    "</div>\n",
    "<div style=\"float:left;width:50%;text-align:right;\">\n",
    "    <h3>Instrumental effects</h3>\n",
    "    <h3>Other stochasticity</h3>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "#### Neural networks are great at learning the data model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### We can build neural networks to deal with parts of the data model we don't understand\n",
    "<img style=\"max-width:65%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/NBM_square.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Extracting physical models from the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "### Correlations between interesting observables and the processes that create them"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "### Can we build neural networks that are informative about these processes?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Neural physical engines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "### Building symmetries into neural networks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "<div style=\"float:left;width:47.5%\">\n",
    "    <img style=\"max-width:100%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/convolutional_network.svg\">\n",
    "</div>\n",
    "<div style=\"float:left;width:5%\"><br></div> \n",
    "<div style=\"float:left;width:47.5%\">\n",
    "    <img style=\"max-width:100%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/spherical_convolutional_network.svg\"><br><br>\n",
    "</div>\n",
    "<div style=\"float:left;width:47.5%\">\n",
    "    <img style=\"max-width:100%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/receptive_field.svg\">\n",
    "</div>\n",
    "<div style=\"float:left;width:5%\"><br></div>\n",
    "<div style=\"float:left;width:47.5%\">\n",
    "    <img style=\"max-width:100%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/kernels.svg\">\n",
    "</div><br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### Decompose neural networks into well structured, orthogonal, algorithms\n",
    "<img style=\"max-width:60%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/data_decomposition.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### Find what part of the data is informative about a given result\n",
    "<br>\n",
    "<div style=\"float:left;width:50%\">\n",
    "    <img style=\"max-width:80%;max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/bad_horse.png\">\n",
    "</div>\n",
    "<div style=\"float:left;width:50%\">\n",
    "    <br>\n",
    "    <b>Use visualising attention to perturb the network to find out what is most sensitive</b>\n",
    "    <br>\n",
    "    <br>\n",
    "    Because of the orthogonal nature of the neural physical engine we can relate physical structures in the data to outcomes from the trained network\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Statistical understanding of neural networks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "<img style=\"max-width:70%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/nn_b_theta.gif\">\n",
    "<center>There is no sense in trust in how correct any output of the network is to be correct</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### Choosing a neural network with weights at their maximum likelihood estimates degenerates the posterior\n",
    "<img style=\"max-width:100%;width:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/posterior_predictive_mle.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Local maximum likelihood estimates\n",
    "<br>\n",
    "<img style=\"max-width:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/wrong_maxima_theta.gif\">\n",
    "<b>Different results are obtained with each network, none with a sense of trust</b>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "# No interpretability and no trust = no science"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Bayesian neural networks and variational inference\n",
    "<img style=\"max-width:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/VB_.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Posterior predictive distribution of outputs\n",
    "<img style=\"max-width:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/vi_b_theta.gif\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "# Everything is dependent on the training data!\n",
    "\n",
    "<br>\n",
    "\n",
    "Classical network : $\\tiny \\mathcal{P}(\\boldsymbol{\\omega},\\boldsymbol{\\alpha}|\\boldsymbol{\\{}{\\bf d},\\boldsymbol{\\theta}\\boldsymbol{\\}}^\\textrm{train}) \\to \\delta(\\boldsymbol{\\omega}-\\boldsymbol{\\omega}^\\textrm{MLE},\\boldsymbol{\\alpha}-\\boldsymbol{\\alpha}^*)$\n",
    "\n",
    "Variational inference : $\\tiny \\mathcal{P}(\\boldsymbol{\\omega},\\boldsymbol{\\alpha}|\\boldsymbol{\\{}{\\bf d},\\boldsymbol{\\theta}\\boldsymbol{\\}}^\\textrm{train}) = \\mathcal{Q}(\\boldsymbol{\\omega}|\\boldsymbol{\\nu}^\\textrm{MLE}, \\boldsymbol{\\alpha}^*, \\boldsymbol{\\{}{\\bf d},\\boldsymbol{\\theta}\\boldsymbol{\\}}^\\textrm{train})$\n",
    "\n",
    "Bayesian networks : $\\tiny \\mathcal{P}(\\boldsymbol{\\omega},\\boldsymbol{\\alpha}|\\boldsymbol{\\{}{\\bf d},\\boldsymbol{\\theta}\\boldsymbol{\\}}^\\textrm{train}) =\\prod_i^{n_\\textrm{train}}\\mathcal{L}(\\boldsymbol{\\theta}^\\textrm{train}_i|{\\bf d}^\\textrm{train}_i,\\boldsymbol{\\omega},\\boldsymbol{\\alpha})p(\\boldsymbol{\\omega},\\boldsymbol{\\alpha})$\n",
    "\n",
    "<img style=\"max-width:80%;width:80%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/posterior_predictive_wrong_theta.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## If the training data, network optimisation, or (pretty much) anything else is not perfect, the inference will be biased"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Likelihood-free inference"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### We have a model with which we can simulate the data \n",
    "- Physical model\n",
    "- Generative models based on neural networks\n",
    "\n",
    "### We cannot (easily) describe the data\n",
    "- The likelihood of obtaining data is unknown/complex\n",
    "- There isn't even a well defined model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### Use the same neural network to summarise observations and simulations\n",
    "<img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/physical_model_nn.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "#### Generate simulations drawn from prior and summarise\n",
    "<img style=\"max-width:100%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/tsims.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Make a kernel density estimate (or use ABC) on the simulations\n",
    "<br>\n",
    "<img style=\"max-width:80%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/LFI_t.svg\">\n",
    "<b>A slice through at the summarised observation is the approximate posterior</b>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "<b>Posterior distribution of galaxy counts and fluxes in fields</b><br><br>\n",
    "<img style=\"max-width:70%;max-height:70%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/ABC_IMNN_noted.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Summary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "##### Neural networks are extremely powerful for science\n",
    "\n",
    "##### They speed up computations\n",
    "\n",
    "##### They can also allow us to build <i>model</i>-independent models\n",
    "\n",
    "##### When used carefully, and in the right setting they give us exact statistically interpretable results\n",
    "\n",
    "##### And in the future they will actually inform us on how to build physical models"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Extracting information using neural networks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "<img style=\"max-height:100%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/IMNN.png\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Information maximising neural networks\n",
    "<br>\n",
    "<div style=\"float:left;width:60%\">\n",
    "    Which function $\\mathscr{f}: \\mathbb{R}^{\\bf d}\\to \\mathbb{R}^\\boldsymbol{\\theta}$ maximises the Fisher information of the summaries ${\\bf x}$ from that function?\n",
    "    <br><br>\n",
    "    $$\\begin{align}\n",
    "    {\\bf F}_{\\alpha\\beta} &= \\left.\\left\\langle\\frac{\\partial^2\\ln\\mathcal{L}({\\bf d}|\\boldsymbol{\\theta})}{\\partial\\theta_\\alpha\\partial\\theta_\\beta}\\right\\rangle\\right|_{\\boldsymbol{\\theta}=\\boldsymbol{\\theta}^*}\\nonumber\\\\\n",
    "    &\\simeq \\left.\\left\\langle\\frac{\\partial^2\\ln\\mathcal{L}({\\bf x}|\\boldsymbol{\\theta}, {\\bf d})}{\\partial\\theta_\\alpha\\partial\\theta_\\beta}\\right\\rangle\\right|_{\\boldsymbol{\\theta}=\\boldsymbol{\\theta}^*}\\nonumber\n",
    "    \\end{align}$$\n",
    "    <br>\n",
    "    <br>\n",
    "    And also Gaussianises the data\n",
    "    $$\\mathcal{L}({\\bf x}|\\boldsymbol{\\theta},{\\bf d})\\approx\\mathcal{N}(\\boldsymbol{\\mu}(\\boldsymbol{\\theta}), \\boldsymbol{\\Sigma}(\\boldsymbol{\\theta}))$$\n",
    "</div>\n",
    "<div style=\"float:left;width:40%\">\n",
    "    <img style=\"max-width:8\n",
    "                90%;max-height:70%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/F.gif\">\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## We maximise\n",
    "$$\\ln|{\\bf F}_{\\alpha\\beta}| = \\ln\\left|\\frac{\\partial\\boldsymbol{\\mu}_\\mathscr{f}}{\\partial\\theta_\\alpha}^T{\\bf C}^{-1}_\\mathscr{f}\\frac{\\partial\\boldsymbol{\\mu}_\\mathscr{f}}{\\partial\\theta_\\beta}\\right|.$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Calculate the covariance\n",
    "<img style=\"max-width:80%;max-height:70%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/covariance.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### Calculate the derivative of the mean of the summaries with respect to the parameters\n",
    "<img style=\"max-width:80%;max-height:70%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/dmdt.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "# Calculate the Fisher information\n",
    "\n",
    "$${\\bf F}_{\\alpha\\beta}=\\frac{\\partial\\mu_\\mathscr{f}}{\\partial\\theta_\\alpha}^T{\\bf C}^{-1}_\\mathscr{f}\\frac{\\partial\\mu_\\mathscr{f}}{\\partial\\theta_\\beta}$$\n",
    "\n",
    "This Gaussian form forces the summaries to be Gaussianised"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "### And use LFI\n",
    "<br>\n",
    "<img style=\"max-width:80%;max-height:60%;display:block;height:auto;margin:auto;float:none!important;\" src=\"../figures/LFI_t.svg\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "These are the optimal summaries to extract information from the data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "# We have lots of examples of how powerful this tool is throughout scientific domains"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "fragment"
    }
   },
   "source": [
    "#### I'm not going to mention them now because each would take an entire seminar to describe 😉"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Diaporama",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "rise": {
   "leap_motion": {
    "naturalSwipe": true,
    "pointerColor": "#d80000",
    "pointerOpacity": 0.5
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
